<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }
        
        .box {
            width: 400px;
            height: 600px;
            border: 1px solid #000;
            margin: 0 auto;
        }
        
        .box1 {
            width: 400px;
            height: 200px;
        }
        
        .box li {
            width: 100px;
            height: 200px;
            line-height: 200px;
            float: left;
            background-color: cornflowerblue;
            text-align: center;
            color: white;
        }
        
        .box2 {
            width: 400px;
            height: 400px;
            display: none;
        }
        
        .box2 li {
            width: 200px;
            height: 200px;
            text-align: center;
            line-height: 200px;
            background-color: burlywood;
            color: white;
            float: left;
        }
        
        .box1 li.active {
            background-color: #666;
        }
        
        .box2.on {
            display: block;
        }
    </style>
</head>

<body>
    <div class="box">
        <!-- 上 -->
        <ul class="box1">
            <li>手机</li>
            <li>电脑</li>
            <li>家居</li>
            <li>服装</li>
        </ul>
        <!-- 下 -->
        <ul class="box2 on">
            <li>内容1</li>
            <li>内容1</li>
            <li>内容1</li>
            <li>内容1</li>
        </ul>
        <ul class="box2">
            <li>内容2</li>
            <li>内容2</li>
            <li>内容2</li>
            <li>内容2</li>
        </ul>
        <ul class="box2">
            <li>内容3</li>
            <li>内容3</li>
            <li>内容3</li>
            <li>内容3</li>
        </ul>
        <ul class="box2">
            <li>内容4</li>
            <li>内容4</li>
            <li>内容4</li>
            <li>内容4</li>
        </ul>
    </div>
    <script>
        let lis = document.querySelectorAll('.box1 li')
        let uls = document.querySelectorAll('.box2')
        console.log(lis, uls)


        lis.forEach(function(v, i) {

            v.addEventListener('click', function() {

                for (let m = 0; m <= lis.length - 1; m++) {
                    lis[m].classList.remove('active')
                    uls[m].classList.remove('on')
                }
                v.classList.add('active')
                uls[i].classList.add('on')
            })
        })
    </script>
</body>

</html>